<template>
	<el-form :model="form" label-width="120px">
		<el-form-item label="订单金额">
			<el-input v-model="form.price" />
		</el-form-item>
		<el-form-item label="下单来源">
			<el-select v-model="form.source" placeholder="please select your zone">
				<el-option :label="v" :value="v" v-for="(v, i) in sourceList" :key="i" />
			</el-select>
		</el-form-item>
		<el-form-item label="支付方式">
			<el-select v-model="form.pay" placeholder="please select your zone">
				<el-option :label="v" :value="v" v-for="(v, i) in payList" :key="i" />
			</el-select>
		</el-form-item>
		<el-form-item label="支付状态">
			<el-radio-group v-model="form.state">
				<el-radio :label="v" v-for="(v, i) in stateList" :key="i"/>
			</el-radio-group>
		</el-form-item>
		<el-form-item>
			<el-button type="primary" @click="onSubmit">创建</el-button>
			<el-button>重置</el-button>
		</el-form-item>
	</el-form>
</template>

<script lang="ts" setup>
import { reactive } from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router';
import { ElMessage } from 'element-plus';
const router = useRouter()
const payList = ["微信", "支付宝", "现金", "银行卡"]
const sourceList = ["app下单", "小程序", "直播"]
const stateList = [
	"未付款",
	"已付款",
	"待发货",
	"已发货",
	"代签收",
	"已签收",
	"已关闭",
]
const form = reactive({
	"price": 0,
	"pay": '',
	"source": '',
	"state": '',
})

const onSubmit = async () => {
	console.log(form)
	const resp = await axios.put('/api/list',  form)
	const { code, message } = resp.data;
	if(code === 200) {
		router.push('/list/manage')
		ElMessage.success(message)
	}
}
</script>
